package com.education.user.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.io.File;

/**
 * @Author: liftSail
 * @Date: 2023/4/14 16:15
 * @Description: 不积跬步无以至千里
 */
@Configuration
public class UploadConfig {

    @Value("${spring.servlet.multipart.location}")
    private String tempDir;

    @PostConstruct
    public void mkDir() {
        //String userDir = System.getProperty("user.dir");
        //File file = new File(userDir + "/tomcat_upload_temp");
        File file = new File(tempDir);
        if (file.exists()) {
            System.out.println("文件夹存在");
        } else {
            System.out.println("文件夹不存在");
            //创建文件夹
            file.mkdirs();
        }
    }

}
